<template>
  <div class="app-container leftTable">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <!-- <el-form-item label="样品名称" prop="ypmc">
        <el-input v-model="queryParams.ypmc" placeholder="请输入样品名称" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item label="生产批次" prop="scpc">
        <el-input v-model="queryParams.scpc" placeholder="请输入生产批次" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="报告日期" prop="bgrq">
        <el-date-picker :editable="false" clearable size="small" v-model="queryParams.bgrq" type="date"
          value-format="yyyy-MM-dd" placeholder="选择报告日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['Laboratory_microbe:microbe:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['Laboratory_microbe:microbe:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['Laboratory_microbe:microbe:remove']">删除</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['Laboratory_microbe:microbe:export']"
          >导出</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-s-check" size="mini" :disabled="multiple" @click="handleCheck"
          v-hasPermi="['Laboratory_microbe:microbe:check']">审核</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="microbeList" @selection-change="handleSelectionChange" max-height="550">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" width="100px" />
      <!-- <el-table-column label="样品名称" align="center" prop="ypmc" /> -->
      <el-table-column label="生产批次" align="center" prop="scpc" />
      <el-table-column label="检测日期" align="center" prop="jcrq" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jcrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报告日期" align="center" prop="bgrq" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bgrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="检验项目" align="center" prop="jcxm" :formatter="laboratory_Microbe_jyxm_Format" width="200">
        <template slot-scope="scope">
          <span>{{ scope.row.jcxm }}</span>
        </template>
      </el-table-column>

      <!-- <el-table-column label="检验依据" align="center" prop="jcyj" />
      <el-table-column label="菌落总数开始时间" align="center" prop="jlstart" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jlstart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="菌落总数截止时间" align="center" prop="jlend" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jlend, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="霉菌-酵母菌开始时间" align="center" prop="mjjmstart" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.mjjmstart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="霉菌-酵母菌截止时间" align="center" prop="mljmend" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.mljmend, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="大肠菌群" align="center" prop="dcqtstart" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcqtstart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="大肠菌群" align="center" prop="dcqtend" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcqtend, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="大肠菌群" align="center" prop="dcstart" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcstart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="大肠菌群" align="center" prop="dcend" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcend, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="铜绿" align="center" prop="tlstart" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tlstart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="铜绿" align="center" prop="tlend" width="190">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tlend, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="报表编号" align="center" prop="bbbh" width="200px" />
      <el-table-column label="检验人" align="center" prop="jyr" />
      <el-table-column label="审核人" align="center" prop="shrPerson" />

      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="250px">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="excelhandleView(scope.row)">导出</el-button>
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['Laboratory_microbe:microbe:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['Laboratory_microbe:microbe:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改微生物检验原始记录（半成品）对话框 -->
    <el-dialog v-myFullscreen fullscreen :title="title" :visible.sync="open" width="1300px" custom-class="myDialog">
      <TableHeader @nameChange="nameChange" :data="{
          mainTitle: '微生物检验原始记录（半成品）',
          company: '青岛崂山矿泉水有限公司',
          code: form.bbbh,
        }" />
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <!-- <el-col :span="6">
            <el-form-item label="样品名称" prop="ypmc">
              
              <Dialog @dialogChange="form.ypmc = $event.label" :echoValue="form.ypmc" parameter="rows" value="id" label="name" :multiple="false" search="name/code" url="/basic/productInfo/listSelect" :column="['产成品编号/code', '产成品名称/name']" placeholder="请选择内容" :axiosData="{ typeCode: 'YYTRKQS' }" :openDisabled="openDisabled" />
            </el-form-item>
          </el-col> -->
          <el-col :span="8">
            <el-form-item label="生产批次" prop="scpc">
              <el-input v-model="form.scpc" placeholder="请输入生产批次" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检测日期" prop="jcrq">
              <el-date-picker :editable="false" clearable v-model="form.jcrq" type="date" value-format="yyyy-MM-dd"
                placeholder="选择检测日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="报告日期" prop="bgrq">
              <el-date-picker :editable="false" clearable v-model="form.bgrq" type="date" value-format="yyyy-MM-dd"
                placeholder="选择报告日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="检验项目" prop="jcxm">
              <!-- <el-input v-model="form.jcxm" placeholder="请输入检验项目" :disabled="openDisabled" /> -->
              <el-checkbox-group v-model="form.jcxmsz" :disabled="openDisabled">
                <el-checkbox v-for="dict in laboratory_Microbe_jyxm" :label="dict.dictLabel"
                  :key="dict.dictValue"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="检验依据" prop="jcyj">
              <el-checkbox-group v-model="form.jcyjsz" :disabled="openDisabled">
                <el-checkbox v-for="dict in laboratory_Microbe_jcyj" :label="dict.dictLabel"
                  :key="dict.dictValue"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- 项目名称 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="项目名称" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="菌落总数（CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="3">
              <el-form-item label="霉菌(CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="3">
              <el-form-item label="酵母菌(CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="大肠菌群(其它饮用水)(CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="大肠菌群(矿泉水)(MPN/100ml)" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="铜绿(矿泉水)(MPN/250ml)" label-width="100%" />
            </el-col>
          </el-row>
          <!-- 培养条件 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="培养条件" label-width="100%" label-position="left" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="36±1℃：48h±2h" label-width="100%" />
            </el-col>
            <el-col :span="6">
              <el-form-item label="28±1℃；5d" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="36±1℃;18～24 h" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="36±1℃;24 h" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="36±1℃；24～48 h" label-width="100%" />
            </el-col>
          </el-row>
          <!-- 开始时间 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="开始时间" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item prop="jlstart" label-width="5px">
                <el-date-picker  @change="datePickerChange($event,'jlend',172800000)" :editable="false" clearable v-model="form.jlstart" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择菌落总数开始时间" :disabled="openDisabled"
                 >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="mjjmstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'mljmend',432000000)" :editable="false" clearable v-model="form.mjjmstart" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择霉菌-酵母菌开始时间" :disabled="openDisabled">
                </el-date-picker >
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcqtstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'dcqtend',86400000)" :editable="false" clearable v-model="form.dcqtstart" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群开始时间" :disabled="openDisabled">
                </el-date-picker >
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'dcend',86400000)" :editable="false" clearable v-model="form.dcstart" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群开始时间" :disabled="openDisabled">
                </el-date-picker >
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="tlstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'tlend',172800000)" :editable="false" clearable v-model="form.tlstart" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择铜绿开始时间" :disabled="openDisabled">
                </el-date-picker >
              </el-form-item>
            </el-col>
          </el-row>
          <!-- 结束时间 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="结束时间" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item prop="jlend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.jlend" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择菌落总数截止时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="mljmend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.mljmend" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择霉菌-酵母菌截止时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcqtend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.dcqtend" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群结束时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.dcend" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群结束时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="tlend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.tlend" type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择铜绿结束时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>

          <!-- <el-col :span="12">
                <el-form-item label="菌落总数开始时间" prop="jlstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.jlstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择菌落总数开始时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="菌落总数截止时间" prop="jlend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.jlend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择菌落总数截止时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="霉菌-酵母菌开始时间" prop="mjjmstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.mjjmstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择霉菌-酵母菌开始时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="霉菌-酵母菌截止时间" prop="mljmend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.mljmend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择霉菌-酵母菌截止时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcqtstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcqtstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcqtend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcqtend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="铜绿" prop="tlstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.tlstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择铜绿" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="铜绿" prop="tlend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.tlend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择铜绿" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="审核人" prop="shrPerson">
                  <el-input v-model="form.shrPerson" placeholder="请输入审核人" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="检验人" prop="jyr">
                  <el-input v-model="form.jyr" placeholder="请输入检验人" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="报表编号" prop="bbbh">
                  <el-input v-model="form.bbbh" placeholder="请输入报表编号" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" placeholder="请输入备注" :disabled="openDisabled" />
                </el-form-item>
            </el-col> -->
        </el-row>
        <br />
        <el-divider content-position="center">微生物检验原始记录（半成品）子1信息</el-divider>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddQualityLabMicrobeSub1"
              :disabled="openDisabled">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddQualityLabMicrobeSub1Null"
              :disabled="openDisabled">添加空白行</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteQualityLabMicrobeSub1"
              :disabled="openDisabled">删除</el-button>
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table :data="qualityLabMicrobeSub1List" :row-class-name="rowQualityLabMicrobeSub1Index" border
          @selection-change="handleQualityLabMicrobeSub1SelectionChange" ref="qualityLabMicrobeSub1"
          :span-method="objectSpanMethod">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="项目名称" width="230" align="center">
            <el-table-column label="序号" align="center" prop="index" width="50" />
            <!-- <el-table-column label="名称" prop="mc" width="130">
              <template slot-scope="scope">
                <div>
                  <el-input placeholder="空白对照组" :disabled="true" />
                </div>
                <div>
                  <el-input
                    v-model="scope.row.mc"
                    placeholder="请输入名称"
                    :disabled="openDisabled"
                  />
                </div>
              </template>
            </el-table-column> -->
            <el-table-column label="样品编号" prop="ypbh" align="center" width="190">
              <template slot-scope="scope">
                <!-- <el-input v-model="scope.row.ypbh" placeholder="请输入样品编号" :disabled="openDisabled"/> -->
                <!-- <div>
                  <el-input
                    v-model="scope.row.ypbhdz"
                    placeholder="请输入样品编号"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-select v-model="scope.row.ypbh" placeholder="请选择样品编号" style="width: 100%"
                    :disabled="openDisabled">
                    <el-option v-for="dict in laboratory_Microbe_bh" :key="dict.dictValue" :label="dict.dictLabel"
                      :value="dict.dictValue"></el-option>
                  </el-select>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="菌落总数（CFU/ml)" width="280" align="center">
            <el-table-column label="平板1" prop="jlzs1" align="center" width="140">
              <template slot-scope="scope">
                <!--  <div>
                  <el-input
                    v-model="form.jlzsdz"
                    placeholder="菌落总数对照"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-input v-model="scope.row.jlzs1" placeholder="请输入菌落总数-平板1" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
            <el-table-column label="平板2" prop="jlzs2" width="140">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input :disabled="true" />
                </div> -->
                <div>
                  <el-input v-model="scope.row.jlzs2" placeholder="请输入菌落总数-平板2" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="霉菌(CFU/ml)" width="150" align="center">
            <el-table-column label="平板1" prop="mjpb1" width="150" align="center">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input
                    v-model="form.mjjmjdz"
                    placeholder="霉菌酵母菌对照"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-input v-model="scope.row.mjpb1" placeholder="请输入霉菌-平板1" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="酵母(CFU/ml)" width="130" align="center">
            <el-table-column label="平板2" prop="jmjpb2" align="center" width="130">
              <template slot-scope="scope">
                <!--  <div>
                  <el-input :disabled="true" />
                </div> -->
                <div>
                  <el-input v-model="scope.row.jmjpb2" placeholder="请输入酵母菌-平板2" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>

          <el-table-column label="大肠菌群（其他饮用水）(CFU/ml)" width="150" align="center">
            <el-table-column label="平板1" prop="dcjqpad1" align="center" width="150">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input
                    v-model="form.dcjqdz"
                    placeholder="大肠菌群对照"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-input v-model="scope.row.dcjqpad1" placeholder="请输入大肠菌群" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
            <el-table-column label="平板2" prop="dcjqpad2" align="center" width="150">
              <template slot-scope="scope">
                <!--  <div>
                  <el-input :disabled="true" />
                </div> -->
                <div>
                  <el-input v-model="scope.row.dcjqpad2" placeholder="请输入大肠菌群" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="大肠菌群（矿泉水）(MPN/100ml)" width="110" align="center">
            <el-table-column label="10ml水样" prop="dcjpsy" align="center" width="260">
              <template slot-scope="scope">
                <el-input v-model="scope.row.dcjpsy" placeholder="请输入大肠菌群" :disabled="openDisabled" />
              </template>
            </el-table-column>
          </el-table-column>

          <el-table-column label="铜绿（矿泉水）(MPN/250ml)" width="720" align="center">
            <el-table-column label="铜绿-蓝/绿色" prop="tlbluegreen" align="center" width="190">
              <template slot-scope="scope">
                <!-- <el-input v-model="scope.row.tlbluegreen" placeholder="请输入铜绿" :disabled="openDisabled"/> -->
                <el-select v-model="scope.row.tlbluegreen" placeholder="请选择铜绿" style="width: 100%"
                  :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                    :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="铜绿-产荧光（非蓝/绿）" align="center" prop="tlnogluegreen" width="190">
              <template slot-scope="scope">
                <!-- <el-input v-model="scope.row.tlnogluegreen" placeholder="请输入铜绿" :disabled="openDisabled"/> -->
                <el-select v-model="scope.row.tlnogluegreen" placeholder="请选择铜绿" style="width: 100%"
                  :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                    :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="铜绿-红褐色" align="center" prop="tlred" width="190">
              <template slot-scope="scope">
                <!-- <el-input v-model="scope.row.tlred" placeholder="请输入铜绿" :disabled="openDisabled"/> -->
                <el-select v-model="scope.row.tlred" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                    :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="铜绿-其他形态" align="center" prop="tlother" width="190">
              <template slot-scope="scope">
                <!-- <el-input v-model="scope.row.tlother" placeholder="请输入铜绿" :disabled="openDisabled"/> -->
                <el-select v-model="scope.row.tlother" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel"
                    :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
          </el-table-column>
          <!-- <el-table-column label="报表编号" prop="bbbh">
            <template slot-scope="scope">
                <el-input v-model="scope.row.bbbh" placeholder="请输入报表编号" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>

        <!-- <el-divider content-position="center">微生物检验原始记录（半成品）子2信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddQualityLabMicrobeSub2" :disabled="openDisabled">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteQualityLabMicrobeSub2" :disabled="openDisabled">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="qualityLabMicrobeSub2List" :row-class-name="rowQualityLabMicrobeSub2Index" @selection-change="handleQualityLabMicrobeSub2SelectionChange" ref="qualityLabMicrobeSub2">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="样品名称" prop="ypmc">
            <template slot-scope="scope">
                <el-input v-model="scope.row.ypmc" placeholder="请输入样品名称" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="样品编号" prop="ypbh">
            <template slot-scope="scope">
                <el-input v-model="scope.row.ypbh" placeholder="请输入样品编号" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="菌落总数" prop="jlzs">
            <template slot-scope="scope">
                <el-input v-model="scope.row.jlzs" placeholder="请输入菌落总数" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="霉菌-酵母菌" prop="mjjmj">
            <template slot-scope="scope">
                <el-input v-model="scope.row.mjjmj" placeholder="请输入霉菌-酵母菌" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群" prop="dcjqother">
            <template slot-scope="scope">
                <el-input v-model="scope.row.dcjqother" placeholder="请输入大肠菌群" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群" prop="dcjqkq">
            <template slot-scope="scope">
                <el-input v-model="scope.row.dcjqkq" placeholder="请输入大肠菌群" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="铜绿" prop="tlkq">
            <template slot-scope="scope">
                <el-input v-model="scope.row.tlkq" placeholder="请输入铜绿" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="openDisabled"/>
            </template>
          </el-table-column>
        </el-table> -->
        <el-row>
          <el-col :span="12">
            <el-form-item label="审核人" prop="shrPerson">
              <el-input v-model="form.shrPerson" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="检验人" prop="jyr">
              <el-select v-model="form.jyr" filterable allow-create placeholder="请选择检验人" style="width: 100%"
                :disabled="openDisabled">
                <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"
                  :disabled="openDisabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {
    listMicrobe,
    getMicrobe,
    delMicrobe,
    addMicrobe,
    updateMicrobe,
    checkMicrobe,
  } from "@/api/quality/laboratory/microbe";
  import { getInfo } from "@/api/login";
  import { listUser } from "@/api/system/user";

  export default {
    name: "Microbe",
    data() {
      return {
        laboratory_Microbe_jyxm: "",
        laboratory_Microbe_jcyj: "",
        //弹窗是否禁止编辑
        openDisabled: true,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 子表选中数据
        checkedQualityLabMicrobeSub1: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 微生物检验原始记录（半成品）表格数据
        microbeList: [],
        // 微生物检验原始记录（半成品）子1表格数据
        qualityLabMicrobeSub1List: [],
        // 微生物检验原始记录（半成品）子2表格数据
        qualityLabMicrobeSub2List: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 50,
          ypmc: null,
          scpc: null,
          bgrq: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        /* 当前用户名 */
        nickName: "",
        userList: [],
      };
    },
    created() {
      this.dict();
      this.getList();
      this.queryUserList();
    },
    methods: {
      dict() {
        this.getDicts("laboratory_Microbe_jyxm").then((response) => {
          this.laboratory_Microbe_jyxm = response.data;
        });
        this.getDicts("laboratory_Microbe_jcyj").then((response) => {
          this.laboratory_Microbe_jcyj = response.data;
        });
        this.getDicts("laboratory_Microbe_bh").then((response) => {
          this.laboratory_Microbe_bh = response.data;
        });
        this.getDicts("laboratory_Microbe_tl").then((response) => {
          this.laboratory_Microbe_tl = response.data;
        });
      },

      /** 查询微生物检验原始记录（半成品）列表 */
      getList() {
        this.loading = true;
        listMicrobe(this.queryParams).then((response) => {
          this.microbeList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 故障类型字典翻译
      laboratory_Microbe_jyxm_Format(row, column) {
        return this.selectDictLabel(this.laboratory_Microbe_jyxm, row.jyxm);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          ypmc: null,
          scpc: null,
          jcrq: null,
          bgrq: null,
          jcxm: null,
          jcxmsz: [],
          jcyj: null,
          jcyjsz: [],
          jlstart: null,
          jlend: null,
          mjjmstart: null,
          mljmend: null,
          dcqtstart: null,
          dcqtend: null,
          dcstart: null,
          dcend: null,
          tlstart: null,
          tlend: null,
          shrPerson: null,
          jyr: this.nickName,
          bbbh: "LK-QF-LS1-10-015-11-05",
          remark: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          delFlag: null,
        };
        this.qualityLabMicrobeSub1List = [];
        this.qualityLabMicrobeSub2List = [];
        this.resetForm("form");
      },
      //日期联动
      datePickerChange(e, key,num) {
        var time = new Date(e).getTime() + num;
        // console.log(e, key,num)
        this.$set(this.form,key,this.parseTime(time, '{y}-{m}-{d} {h}:{i}:{s}'))
        // console.log(time)
        // console.log(this.parseTime(time, '{y}-{m}-{d} {h}:{i}:{s}'))
      },
      /** 搜索按钮操作 */
      
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map((item) => item.id);
        this.single = selection.length !== 1;
        this.multiple = !selection.length;
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.dict();
        this.reset();
        this.openDisabled = false;
        this.open = true;
        this.title = "添加微生物检验原始记录（半成品）";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.dict();
        this.reset();
        this.openDisabled = false;
        const id = row.id || this.ids;
        getMicrobe(id).then((response) => {
          this.form = response.data;
          this.qualityLabMicrobeSub1List =
            response.data.qualityLabMicrobeSub1List;
          this.qualityLabMicrobeSub2List =
            response.data.qualityLabMicrobeSub2List;
          this.open = true;
          this.title = "修改微生物检验原始记录（半成品）";
        });
      },
      /** 查看按钮 */
      handleView(row) {
        this.dict();
        this.reset();
        this.openDisabled = true;
        const id = row.id || this.ids;
        getMicrobe(id).then((response) => {
          this.form = response.data;
          this.qualityLabMicrobeSub1List =
            response.data.qualityLabMicrobeSub1List;
          this.qualityLabMicrobeSub2List =
            response.data.qualityLabMicrobeSub2List;
          this.open = true;
          this.title = "查看微生物检验原始记录（半成品）";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            this.form.qualityLabMicrobeSub1List = this.qualityLabMicrobeSub1List;
            this.form.qualityLabMicrobeSub2List = this.qualityLabMicrobeSub2List;
            /**打开遮罩层*/
            const rLoading = this.openLoading();
            if (this.form.id != null) {
              updateMicrobe(this.form)
                .then((response) => {
                  /**成功后执行关闭遮罩层*/
                  rLoading.close();
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                })
                .catch((error) => {
                  /**请求异常后执行关闭遮罩层*/
                  rLoading.close();
                });
            } else {
              addMicrobe(this.form)
                .then((response) => {
                  /**成功后执行关闭遮罩层*/
                  rLoading.close();
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
                })
                .catch((error) => {
                  /**请求异常后执行关闭遮罩层*/
                  rLoading.close();
                });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm(
          '是否确认删除微生物检验原始记录（半成品）编号为"' + ids + '"的数据项?',
          "警告",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        )
          .then(function () {
            return delMicrobe(ids);
          })
          .then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          })
          .catch(() => { });
      },
      /** 微生物检验原始记录（半成品）子1序号 */
      rowQualityLabMicrobeSub1Index({ row, rowIndex }) {
        row.index = rowIndex + 1;
      },
      /* 合并列 */
      objectSpanMethod({ row, column, rowIndex, columnIndex }) {
        if (rowIndex === 0) {
          // console.log(rowIndex);
          // console.log(columnIndex);
          if (columnIndex === 3) {
            return [1, 2];
          }
          if (columnIndex === 4) {
            return [0, 0];
          }
          if (columnIndex === 5) {
            return [1, 2];
          }
          if (columnIndex === 6) {
            return [0, 0];
          }
          if (columnIndex === 7) {
            return [1, 2];
          }
          if (columnIndex === 8) {
            return [0, 0];
          }
          if (columnIndex === 10) {
            return [1, 4];
          }
          if (columnIndex === 11) {
            return [0, 0];
          }
          if (columnIndex === 12) {
            return [0, 0];
          }
          if (columnIndex === 13) {
            return [0, 0];
          }
        }
        // return {
        //       rowspan: 2,
        //       colspan: 1
        //     };

        // if (columnIndex === 0) {
        // if (rowIndex % 2 === 0) {
        //   return {
        //     rowspan: 2,
        //     colspan: 1
        //   };
        // } else {
        //   return {
        //     rowspan: 0,
        //     colspan: 0
        //   };
        // }
        // if (columnIndex === 0) {
        //   const _row = this.flitterData(this.qualityProdHygieneSubList).one[rowIndex];
        //   const _col = _row > 0 ? 1 : 0;
        //   return {
        //     rowspan: _row,
        //     colspan: _col,
        //   };
        // }
        // }
      },
      handleAddQualityLabMicrobeSub1Null() {
        let obj = {};
        obj.mc = "";
        obj.ypbh = "";
        obj.jlzs1 = "0";
        obj.jlzs2 = "0";
        obj.mjpb1 = "0";
        obj.jmjpb2 = "0";
        obj.dcjqpad1 = "空";
        obj.dcjqpad2 = "空";
        obj.dcjpsy = "0";
        obj.tlbluegreen = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlnogluegreen = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlred = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlother = this.laboratory_Microbe_tl[0].dictValue;
        obj.bbbh = "";
        obj.remark = "";
        //对照组
        obj.ypbhdz = "0";
        obj.jlzsdz = "";
        obj.mjjmjdz = "";
        obj.dcjqdz = "空";
        obj.dcjpsydz = "空";
        this.qualityLabMicrobeSub1List.push(obj);
      },
      /** 微生物检验原始记录（半成品）子1添加按钮操作 */
      handleAddQualityLabMicrobeSub1() {
        let obj = {};
        obj.mc = "";
        obj.ypbh = "";
        obj.jlzs1 = "0";
        obj.jlzs2 = "0";
        obj.mjpb1 = "0";
        obj.jmjpb2 = "0";
        obj.dcjqpad1 = "空";
        obj.dcjqpad2 = "空";
        obj.dcjpsy = "0";
        obj.tlbluegreen = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlnogluegreen = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlred = this.laboratory_Microbe_tl[0].dictValue;
        obj.tlother = this.laboratory_Microbe_tl[0].dictValue;
        obj.bbbh = "";
        obj.remark = "";
        //对照组
        obj.ypbhdz = "0";
        obj.jlzsdz = "";
        obj.mjjmjdz = "";
        obj.dcjqdz = "空";
        obj.dcjpsydz = "空";
        this.qualityLabMicrobeSub1List.push(obj);
      },
      /** 微生物检验原始记录（半成品）子1删除按钮操作 */
      handleDeleteQualityLabMicrobeSub1() {
        if (this.checkedQualityLabMicrobeSub1.length == 0) {
          this.$alert(
            "请先选择要删除的微生物检验原始记录（半成品）子1数据",
            "提示",
            { confirmButtonText: "确定" }
          );
        } else {
          this.qualityLabMicrobeSub1List.splice(
            this.checkedQualityLabMicrobeSub1[0].index - 1,
            1
          );
        }
      },
      /** 单选框选中数据 */
      handleQualityLabMicrobeSub1SelectionChange(selection) {
        if (selection.length > 1) {
          this.$refs.qualityLabMicrobeSub1.clearSelection();
          this.$refs.qualityLabMicrobeSub1.toggleRowSelection(selection.pop());
        } else {
          this.checkedQualityLabMicrobeSub1 = selection;
        }
      },
      /** 微生物检验原始记录（半成品）子2序号 */
      rowQualityLabMicrobeSub2Index({ row, rowIndex }) {
        row.index = rowIndex + 1;
      },
      /** 微生物检验原始记录（半成品）子2添加按钮操作 */
      handleAddQualityLabMicrobeSub2() {
        let obj = {};
        obj.ypmc = "";
        obj.ypbh = "";
        obj.jlzs = "";
        obj.mjjmj = "";
        obj.dcjqother = "";
        obj.dcjqkq = "";
        obj.tlkq = "";
        obj.remark = "";
        this.qualityLabMicrobeSub2List.push(obj);
      },
      /** 微生物检验原始记录（半成品）子2删除按钮操作 */
      handleDeleteQualityLabMicrobeSub2() {
        if (this.checkedQualityLabMicrobeSub2.length == 0) {
          this.$alert(
            "请先选择要删除的微生物检验原始记录（半成品）子2数据",
            "提示",
            { confirmButtonText: "确定" }
          );
        } else {
          this.qualityLabMicrobeSub2List.splice(
            this.checkedQualityLabMicrobeSub2[0].index - 1,
            1
          );
        }
      },
      /** 单选框选中数据 */
      handleQualityLabMicrobeSub2SelectionChange(selection) {
        if (selection.length > 1) {
          this.$refs.qualityLabMicrobeSub2.clearSelection();
          this.$refs.qualityLabMicrobeSub2.toggleRowSelection(selection.pop());
        } else {
          this.checkedQualityLabMicrobeSub2 = selection;
        }
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download(
          "Laboratory_microbe/microbe/export",
          {
            ...this.queryParams,
          },
          `Laboratory_microbe_microbe.xlsx`
        );
      },

      excelhandleView(row) {
        this.download(
          "Laboratory/microbe/exportexcel?id=" + row.id,
          {
            ...this.queryParams,
          },
          "微生物检验原始记录（半成品）" + this.parseTime(new Date()) + ".xlsx"
        );
      },
      //接收编号
      nameChange(e) {
        this.form.bbbh = e;
      },
      /* 合并两行 */
      // objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      //   if (columnIndex === 0) {
      //     if (rowIndex % 2 === 0) {
      //       return {
      //         rowspan: 2,
      //         colspan: 1,
      //       };
      //     } else {
      //       return {
      //         rowspan: 0,
      //         colspan: 0,
      //       };
      //     }
      //   }
      // },
      /** 审核按钮操作 */
      handleCheck(row) {
        /* 审核 */
        this.ids.forEach((id) => {
          getMicrobe(id).then((response) => {
            if (
              response.data.shrPerson != null &&
              response.data.shrPerson != ""
            ) {
              this.msgError(
                '编号为"' + id + '"的数据项已审核完成，无需重复审核！'
              );
            } else {
              let obj = {};
              obj.id = id;
              obj.shrPerson = this.nickName;
              obj.qualityLabMicrobeSub1List = this.qualityLabMicrobeSub1List;
              obj.qualityLabMicrobeSub2List = this.qualityLabMicrobeSub2List;
              /* 修改 */
              checkMicrobe(obj).then((response) => {
                this.msgSuccess('编号为"' + id + '"的数据项审核成功！');
                this.getList();
              });
            }
          });
        });
      },
      /* 查询用户列表 */
      queryUserList() {
        listUser().then((response) => {
          this.userList = response.rows;
        });
        getInfo().then((response) => {
          this.nickName = response.user.nickName;
        });
      },
    },
  };
</script>
<style>
  .leftTable .el-form-item__label {
    text-align: left !important;
  }

  .leftTable .center .el-form-item__label {
    text-align: center !important;
  }
</style>